import { defineStore } from 'pinia';
import Api from '../script/Api';

const empty = {
  user: {},
  userInfo: {},
  role: {},
  exinfo: {},
};

const store = defineStore('user', {
  state: () => {
    return {
      isLogin: false,
      user: empty,
   
    };
  },
  actions: {
    getLoginInfo() {
      let instance = this;
      Api.post('/user/getLoginInfo', {}, (data) => {
        if (data.success) {
          instance.isLogin = true;
          instance.user = data;
          console.log('已登录');
        } else {
          instance.isLogin = false;
          instance.user = empty;
          console.log('未登录');
        }
        
      });
    },
  },
});

export default store;
